<template>
	<view>
		<view class="usercard">
			<view class="avatar">
				<image src="/static/icon/my.png" mode="widthFix" style="width:160upx; height:160upx;"></image>
			</view>
			<view class="nickname">{{info.username}}</view>
		</view>
		<view class="actionList">
			<view class="alistItem" @tap="needLoginToNav('/pages/my/changeInfo')">
				<view class="label" >修改资料</view>
				<u-icon name="arrow-right"></u-icon>
			</view>
			<view class="alistItem" @tap="needLoginToNav('/pages/my/changePwd')">
				<view class="label">修改密码</view>
				<u-icon name="arrow-right"></u-icon>
			</view>
			<view class="alistItem" @tap="exit">
				<view class="label">退出登录</view>
				<u-icon name="arrow-right"></u-icon>
			</view>
		</view>
	</view>
</template>

<script>
import helper from '../../common/helper';
import api from '@/api.js';
	
	export default {
		mixins:[helper],
		data() {
			return {
				info:{}
			}
		},
		onLoad(e){
			if(uni.getStorageSync('token')==''){
				uni.navigateTo({
					url:'/pages/login/login'
				})
			}
			api.doRequest('get','my/info').then(res=>{
				if(res.statusCode==200){
					this.info=res.data.data;
				}
			})
		},
		methods: {
			exit(){
				uni.setStorageSync('token','');
				uni.reLaunch({
					url:'/pages/login/login'
				})
			}
		}
	}
</script>

<style>
	.usercard{
		width:calc(100% - 40upx); background:#004ea2;height:400upx;
		padding:20upx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	.nickname{color:#fff;line-height:80upx;}
.alistItem{
	width:calc(100% - 40upx);
	padding:0 20upx;
	height:80upx;
	border-bottom:1upx solid #ccc;
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.avatar{
	width:200upx; height:200upx;background:#fff;display: flex;align-items: center;justify-content: center;
	border-radius:100upx;
}
</style>
